<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改后台账户</title>
    <link href="$!webPath/css/template.css" rel="stylesheet" type="text/css"/>
    <link href="$!webPath/css/jquery-ui-1.8.22.custom.css" type="text/css" rel="stylesheet">
    <script src="$!webPath/js/jquery-1.6.2.js"></script>
    <script src="$!webPath/js/jquery-ui-1.8.21.js"></script>
    <script src="$!webPath/js/ajaxfileupload.js"></script>
    <script>

        $(function () {
            if('$!adminUser.id'!=''){
                $('.set_pass').css('display','none');
                $('#userName').attr('readonly','readonly');
            }
        })
        //商品图片ajax上传
        function upload_goods_img(){
            jQuery.ajaxFileUpload({
                url:'',
                dataType:'json',
                fileElementId:['goodsPhoto'],
                success:function(data){
                    jQuery(".upload_pictures_top_img img").attr("src","");
                    jQuery('#pictureName').val(data.name);
                }
            });
        }
    </script>
    <style type="text/css">
        label.error {
            color: #F00;
            margin-left: 3px;
        }

        input.error {
            border: 2px solid #F00;
        }
        .cont_right{
            float: right;
            margin: 0 30px 10px 0;
        }
        .cont_right a{
            text-decoration: none;
        }
    </style>
</head>
<body>
<div class="header_nav">
    <iframe name="content_frame" src="$!webPath/admin/nav" marginwidth=0 marginheight=0  frameborder=0 width=100% height=80/></iframe>
    <div class="cont_right"><a href="$!webPath/login">注销</a></div>
</div>
    <div class="cont">
        <h3 class="seth">编辑</h3>
        <div class="nav_list">
            <ul id="ul_table">
                <li><a href="$!webPath/admin/admin_list?size=10&page=0"><b>管理员列表</b></a></li>
                <li><a href="javascript:void(0);" class="this"><b>编辑</b></a></li>
            </ul>
        </div>
        <div class="adddetail">
            <form action="$!webPath/admin/" method="post" name="theForm" id="theForm">
                <div class="edit">
                    <div class="setcont editul">

                        <ul class="set1">
                            <li class="setcont_bg">管理员名</li>
                            <li>
                                <input id="userName" type="text" value="$!adminUser.userName" size="30">
                            </li>
                        </ul>
                        <ul class="set1 set_pass" style="display: block;">
                            <li class="setcont_bg">密码</li>
                            <li>
                                <input id="password" type="password" value="$!adminUser.password" size="30">
                            </li>
                        </ul>
                        <ul class="set1">
                            <li class="setcont_bg">状态</li>
                            <li>
                                #if($!adminUser.userStatus==1)
                                <input type="radio" name="userStatus" value="1" checked> 正常
                                <input type="radio" name="userStatus" value="0"> 异常
                                #else
                                <input type="radio" name="userStatus" value="1" > 正常
                                <input type="radio" name="userStatus" value="0" checked> 异常
                                #end
                            </li>
                        </ul>
                        <ul class="set1">
                            <li class="setcont_bg">手机号</li>
                            <li>
                            <span class="webname">
                              <input id="mobile" type="text" value="$!adminUser.mobile" size="30">
                            </span>
                            </li>
                        </ul>
                        <ul class="set1">
                            <li class="setcont_bg">管理员类型</li>
                            <li>
                            <span class="webname">
                              <input id="adminType" type="radio" value="1" checked readonly>管理员
                            </span>
                            </li>
                        </ul>

                    </div>
                </div>


            </form>
            <div class="submit">
            <span class="pad120">
        <input name="save" type="button" value="提交" id="saveForm">
        </span>
            </div>
        </div>
    </div>
<script>
    var userName=$('#userName').blur(function () {
        var userName=$('#userName').val();
        $.ajax({
            url:'$!webPath/admin/validate_admin_name',
            type:'post',
            data:{userName:userName},
            success:function(data){
                if(data.data!='success'){
                    alert(data.data);
                    console.log(data);
                    return false;
                }else{
                    return userName;
                }
            },
            error: function () {

            }
        })
    })
    $('#saveForm').click(function () {
        var userName=$('#userName').val();
        var password=$('#password').val();
        var userStatus=$('input[name="userStatus"]:checked').val();
        var mobile=$('#mobile').val();
        var adminType=$('#adminType').val();
        if(userName==''||password==''||mobile==''){
            alert('管理员名，密码，手机号码不能为空');
            return false
        }
        var get_data={
            adminUserId:'$!adminUser.id',
            userName:userName,
            password:password,
            userStatus:userStatus,
            mobile:mobile,
            adminType:adminType
        }
        $.ajax({
            url:'$!webPath/admin/admin_add',
            type:'post',
            data:get_data,
            success:function(){
                window.location.href = "$!webPath/admin/admin_list?size=10&page=0";
            },
            error: function () {
                alert('失败');
            }
        })
    })
</script>
</body>
</html>